/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.dinner.service.balance;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.dinner.dao.balance.ResAccountBalanceDao;
import com.thinkgem.jeesite.modules.dinner.entity.balance.ResAccountBalance;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * 余额管理Service
 * @author dai
 * @version 2018-11-18
 */
@Service
@Transactional(readOnly = true)
public class ResAccountBalanceService extends CrudService<ResAccountBalanceDao, ResAccountBalance> {

	public ResAccountBalance get(String id) {
		return super.get(id);
	}
	
	public List<ResAccountBalance> findList(ResAccountBalance resAccountBalance) {
		return super.findList(resAccountBalance);
	}
	
	public Page<ResAccountBalance> findPage(Page<ResAccountBalance> page, ResAccountBalance resAccountBalance) {
		return super.findPage(page, resAccountBalance);
	}
	
	@Transactional(readOnly = false)
	public void save(ResAccountBalance resAccountBalance) {
		super.save(resAccountBalance);
	}
	
	@Transactional(readOnly = false)
	public void delete(ResAccountBalance resAccountBalance) {
		super.delete(resAccountBalance);
	}

    public ResAccountBalance findByUserId(String id) {
		return dao.findByUserId(id);
    }

	@Transactional(readOnly = false)
	public void updateBalanceByUserId(String id, double balance) {
		dao.updateBalanceByUserId(balance,UserUtils.getUser().getId(),new Date(),id);
	}
}